﻿using System;
using System.Collections.ObjectModel;
using System.Diagnostics.Contracts;
using System.Windows;

namespace MoneyManager
{
    public enum CategoryType { Expense, Income, Both }

    public class Category : ICloneable
    {
        public int Id { get; set; }
        public String Name { get; set; }
        public String Image { get; set; }
        public String Description { get; set; }
        public CategoryType Type { get; set; }
        public ObservableCollection<Transaction> Transactions { get; private set; }

        public Category() 
        {
            Id = ConstantsAndDefaultValuesClass.ObjectIsNotInDb;
            Image = ConstantsAndDefaultValuesClass.DefaultImage;
            Type = ConstantsAndDefaultValuesClass.DefaultCategoryType;
            Transactions = new ObservableCollection<Transaction>();
        }

        public void Validate()
        {
            //try
            //{
            Contract.Requires(this.Name != null, "Category name should be set");
            //}
            //catch (Exception e)
            //{
            //    MessageBox.Show(e.Message);
            //}
        }

        public void CopyFields(Category category)
        {
            Name = category.Name;
            Image = category.Image;
            Description = category.Description;
        }

        #region ICloneable Members

        public object Clone()
        {
            return MemberwiseClone();
        }

        #endregion

        public override String ToString()
        {
 	        return Name;
        }
    }
}
